﻿using System.Collections.Generic;
using DiNinject.EfModel;
using DiNinject.Repository.Interfaces;
using DiNinject.Web.UI.Models.Autos.ModelInterfaces;

namespace DiNinject.Web.UI.Models.Autos
{
    public class AutoListModel : IAutoListModel
    {
        #region Member
        public List<AutoViewModel> AutoList { get; set; }

        public AutoListModel()
        {
            AutoList = new List<AutoViewModel>();
        }
        #endregion

        #region Public Functions
        /// <summary>
        /// Laden der Anzeige für ein Auto
        /// </summary>
        public void Load(IAutoRespository autoRespository)
        {
            var dBModel = autoRespository.AllAutos();
            foreach (Auto auto in dBModel)
            {
                AutoViewModel viewModel = new AutoViewModel();
                viewModel.IsLuxusMarke = auto.Marke == "BMW";
                viewModel.Marke = auto.Marke;
                viewModel.Nummernschild = auto.Nummernschild;
                viewModel.Id = auto.Id;
                AutoList.Add(viewModel);
            }
        }
        #endregion
    }
}